<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>仿百度注册</title>
    <link rel="stylesheet" href="css/custom.css">
</head>
<body>
<form>
<div class="register">
    <p>
        <label>用户名</label><input type="text" placeholder="请设置用户名" id="username"><span id="userinfo"></span>
    </p>
    <p>
        <label>手机号</label><input type="text" placeholder="请填写手机号"><span id="telinfo"></span>
    </p>
    <p>
        <label>密码</label><input type="text" placeholder="请设置用户密码" ><span id="passinfo">111</span>
    </p>
    <p>
        <label>验证码</label>
        <input type="text" placeholder="验证码" style="width: 205px">
        <input type="button" value="点击获取验证码" style="width: 143px">
    </p>
    <p style="margin-left: 75px;font-size: 12px">
        <input type="checkbox" required="required"> 阅读并接受<a href="#">《百度用户协议》</a>及<a href="#">《百度隐私权保护声明》</a>
    </p>
    <p style="margin-left: 75px;">
        <input type="submit" value="注册">
    </p>
</div>
</form>
<script>
    document.getElementById('username').onblur = function () {
        if(this.value.length < 5 || this.value.length > 15){
            document.getElementById('userinfo').innerHTML = "<img src='imgs/err_small.png'> 用户名长度为6-15之间";
            this.style.borderColor = "red";
        }else{
            document.getElementById('userinfo').innerHTML = "<img src='imgs/ok_small.png'>";
            this.style.borderColor = "black";
        }
    }
</script>
</body>
</html>